package com.heima.wemedia.controller.v1;

import com.heima.model.admin.dtos.NewsAutoDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description TODO
 * @Author bo.li
 * @Date 2023/3/16 11:08
 * @Version 1.0
 */
@RestController
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    @PostMapping("/api/v1/news/list")
    public ResponseResult list(@RequestBody WmNewsPageReqDto reqDto){

        return wmNewsService.pageList(reqDto);
    }

    @PostMapping("/api/v1/news/submit")
    public ResponseResult submit(@RequestBody WmNewsDto newsDto){
        return wmNewsService.submit(newsDto);
    }



    @PostMapping("/news/getList")
    ResponseResult getListNews(@RequestBody NewsAutoDto newsAutoDto){
        return wmNewsService.getListNews(newsAutoDto);
    }

    @GetMapping("/news/getDetails/{id}")
    ResponseResult getDetailsNews(@PathVariable Integer id){
        return wmNewsService.getDetailsNews(id);
    }

    @PostMapping("/news/pass")
    ResponseResult passNews(@RequestBody NewsAutoDto newsAutoDto){
        return wmNewsService.passNews(newsAutoDto);
    }

    @PostMapping("/news/fail")
    public ResponseResult failNews(@RequestBody NewsAutoDto newsAutoDto){
        return wmNewsService.failNews(newsAutoDto);
    };
}